//
//  ZCstrategyVC.m
//  zctx
//
//  Created by apple on 16/1/6.
//  Copyright © 2016年 sanliang. All rights reserved.
//

#import "ZCstrategyVC.h"
#import "ZCRaiseVC.h"
@interface ZCstrategyVC ()

@end

@implementation ZCstrategyVC
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"ZCstrategyVC"];
    [MTA trackPageViewBegin:@"ZCstrategyVC"];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"ZCstrategyVC"];
    [MTA trackPageViewEnd:@"ZCstrategyVC"];
    self.tabBarController.hidesBottomBarWhenPushed = NO;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"众测攻略";
    [self initnavegation];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self.view addSubview:scroll];
    scroll.bounces = NO;
    
    
    // 1.创建UIImageView（图片）
    UIImageView *imageView = [[UIImageView alloc] init];
    if (IS_IPHONE_4_OR_LESS) {
        imageView.image = [UIImage imageNamed:@"me_strategy"];
    }else if (IS_IPHONE_5){
        imageView.image = [UIImage imageNamed:@"me_strategy"];
    }else if (IS_IPHONE_6){
        imageView.image = [UIImage imageNamed:@"me_strategy"];
    }else{
        imageView.image = [UIImage imageNamed:@"me_strategy"];
    }
    CGFloat imgW = imageView.image.size.width; // 图片的宽度
    CGFloat imgH = imageView.image.size.height; // 图片的高度
    imageView.frame = CGRectMake(0, 0,SCREEN_WIDTH,imgH * (SCREEN_WIDTH/imgW));
    [scroll addSubview:imageView];
    
    // 2.创建UIImageView（图片）
    UIImageView *imageView1 = [[UIImageView alloc] init];
    if (IS_IPHONE_4_OR_LESS) {
        imageView1.image = [UIImage imageNamed:@"me_strategy1"];
    }else if (IS_IPHONE_5){
        imageView1.image = [UIImage imageNamed:@"me_strategy1"];
    }else if (IS_IPHONE_6){
        imageView1.image = [UIImage imageNamed:@"me_strategy1"];
    }else{
        imageView1.image = [UIImage imageNamed:@"me_strategy1"];
    }
    CGFloat imgW1 = imageView1.image.size.width; // 图片的宽度
    CGFloat imgH1 = imageView1.image.size.height; // 图片的高度
    imageView1.frame = CGRectMake(0,imgH * (SCREEN_WIDTH/imgW)-1,SCREEN_WIDTH,imgH1 * (SCREEN_WIDTH/imgW1));
    [scroll addSubview:imageView1];
    imageView1.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Clickraise)];
    [imageView1 addGestureRecognizer:recognizer];
    
    //3.创建UIImageView（图片）
    UIImageView *imageView2 = [[UIImageView alloc] init];
    if (IS_IPHONE_4_OR_LESS) {
        imageView2.image = [UIImage imageNamed:@"me_strategy2"];
    }else if (IS_IPHONE_5){
        imageView2.image = [UIImage imageNamed:@"me_strategy2"];
    }else if (IS_IPHONE_6){
        imageView2.image = [UIImage imageNamed:@"me_strategy2"];
    }else{
        imageView2.image = [UIImage imageNamed:@"me_strategy2"];
    }
    CGFloat imgW2 = imageView2.image.size.width; // 图片的宽度
    CGFloat imgH2 = imageView2.image.size.height; // 图片的高度
    imageView2.frame = CGRectMake(0,imgH * (SCREEN_WIDTH/imgW)+imgH1 * (SCREEN_WIDTH/imgW1)-2,SCREEN_WIDTH,imgH2 * (SCREEN_WIDTH/imgW2));
    [scroll addSubview:imageView2];

    // 3.设置scrollView的属性
    
    // 设置UIScrollView的滚动范围（内容大小）
    scroll.contentSize = CGSizeMake(SCREEN_WIDTH, imgH * (SCREEN_WIDTH/imgW)+imgH1 * (SCREEN_WIDTH/imgW1)+imgH2 * (SCREEN_WIDTH/imgW2)-2);
}

#pragma mark 导航栏
-(void)initnavegation{
    
    UIButton * leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    leftButton.frame = CGRectMake(0, 0, 19, 36);
    [leftButton setImage:[UIImage imageNamed:@"navigation_back"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(backButtonPressed) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * barButtonItem_leftNavBar = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = barButtonItem_leftNavBar;
}

//发起众筹
-(void)Clickraise{
    NSLog(@"sdf");
    ZCRaiseVC  *raise = [[ZCRaiseVC alloc]init];
    raise.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:raise animated:YES];
}

-(void)backButtonPressed{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
